package com.ruoyi.ifmReward.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.ifmReward.domain.IfmReward;
import com.ruoyi.ifmReward.service.IIfmRewardService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 奖励Controller
 * 
 * @author ruoyi
 * @date 2024-11-01
 */
@RestController
@RequestMapping("/ifmReward/ifmReward")
public class IfmRewardController extends BaseController
{
    @Autowired
    private IIfmRewardService ifmRewardService;

    /**
     * 查询奖励列表
     */
    @PreAuthorize("@ss.hasPermi('ifmReward:ifmReward:list')")
    @GetMapping("/list")
    public TableDataInfo list(IfmReward ifmReward)
    {
        startPage();
        List<IfmReward> list = ifmRewardService.selectIfmRewardList(ifmReward);
        return getDataTable(list);
    }

    /**
     * 导出奖励列表
     */
    @PreAuthorize("@ss.hasPermi('ifmReward:ifmReward:export')")
    @Log(title = "奖励", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, IfmReward ifmReward)
    {
        List<IfmReward> list = ifmRewardService.selectIfmRewardList(ifmReward);
        ExcelUtil<IfmReward> util = new ExcelUtil<IfmReward>(IfmReward.class);
        util.exportExcel(response, list, "奖励数据");
    }

    /**
     * 获取奖励详细信息
     */
    @PreAuthorize("@ss.hasPermi('ifmReward:ifmReward:query')")
    @GetMapping(value = "/{rewardId}")
    public AjaxResult getInfo(@PathVariable("rewardId") Long rewardId)
    {
        return success(ifmRewardService.selectIfmRewardByRewardId(rewardId));
    }

    /**
     * 新增奖励
     */
    @PreAuthorize("@ss.hasPermi('ifmReward:ifmReward:add')")
    @Log(title = "奖励", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody IfmReward ifmReward)
    {
        return toAjax(ifmRewardService.insertIfmReward(ifmReward));
    }

    /**
     * 修改奖励
     */
    @PreAuthorize("@ss.hasPermi('ifmReward:ifmReward:edit')")
    @Log(title = "奖励", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody IfmReward ifmReward)
    {
        return toAjax(ifmRewardService.updateIfmReward(ifmReward));
    }

    /**
     * 删除奖励
     */
    @PreAuthorize("@ss.hasPermi('ifmReward:ifmReward:remove')")
    @Log(title = "奖励", businessType = BusinessType.DELETE)
	@DeleteMapping("/{rewardIds}")
    public AjaxResult remove(@PathVariable Long[] rewardIds)
    {
        return toAjax(ifmRewardService.deleteIfmRewardByRewardIds(rewardIds));
    }
}
